@using ZR.CodeGenerator
@using ZR.Model.System.Generate
@using Infrastructure.Extensions;
@* @model ZR.CodeGenerator.Model.GenerateDto; *@
@{
    var genTable = Model.GenTable;
    var subTableOptions = Model.SubTableOptions;
    var options = Model.GenOptions;
    var replaceDto = Model.ReplaceDto;
    var dictHtml = new string[] { GenConstants.HTML_CHECKBOX, GenConstants.HTML_RADIO, GenConstants.HTML_SELECT, GenConstants.HTML_SELECT_MULTI };
    var dicts = new List<GenTableColumn>();
    dicts.AddRange(Model.GenTable.Columns.FindAll((Predicate<GenTableColumn>)(f => dictHtml.Contains(f.HtmlType))));
    if (Model.GenTable.SubTable != null && Model.GenTable.SubTableName.IsNotEmpty())
    {
        dicts.AddRange(Model.GenTable?.SubTable?.Columns?.FindAll((Predicate<GenTableColumn>)(f => dictHtml.Contains(f.HtmlType))));
    }
}
@if (null != genTable.SubTableName && "" != genTable.SubTableName)
{
@:using @(subTableOptions.ModelsNamespace).@(subTableOptions.SubNamespace);
}

namespace @(options.DtosNamespace).@(options.SubNamespace).Dto
{
    /// <summary>
    /// @(genTable.FunctionName)查询对象
    /// </summary>
    public class @(replaceDto.ModelTypeName)QueryDto : PagerInfo 
    {
@foreach (var item in genTable.Columns)
{
    if (item.IsQuery)
    {
        if (item.HtmlType.StartsWith("date"))
        {
        @:public DateTime? Begin@(item.CsharpField){get; set; }
        @:public DateTime? End@(item.CsharpField){get; set; }
        }
        else if (item.HtmlType == "selectMulti")
        {
        @:public @(item.CsharpType)[] @item.CsharpField { get; set; }
        }
        else
        {
        @:public @item.CsharpType@(item.CsharpType != "string" ? "?" : "") @item.CsharpField { get; set; }
        }
@:
    }
}
    }

    /// <summary>
    /// @(genTable.FunctionName)输入输出对象
    /// </summary>
    public class @(replaceDto.ModelTypeName)Dto
    {
@foreach (var item in genTable.Columns)
{
    var labelName = "";
    if (item.FieldDesc != "")
    {
        labelName = item.FieldDesc;
    }
    else
    {
        labelName = item.CsharpField;
    }
    if (item.IsRequired==true)
    {
        @:[Required(ErrorMessage = "@(item.FieldDesc)不能为空")]
    }
    if (replaceDto.ShowBtnExport)
    {
        if (item.IsExport)
        {
        @:[ExcelColumn(Name = "@labelName"@(item.CsharpType == "DateTime" ? ", Format = \"yyyy-MM-dd HH:mm:ss\", Width = 20" : ""))]
        @:[ExcelColumnName("@labelName")]
        }
        else
        {
        @:[ExcelIgnore]
        }
    }
    if (item.CsharpType == "long" && replaceDto.UseSnowflakeId == true && item.IsPk)
    {
        @:[JsonConverter(typeof(ValueToStringConverter))]
    }
        @:public @item.CsharpType@item.RequiredStr @item.CsharpField { get; set; }
@:

}

@if (genTable.TplCategory == "subNav" && genTable.SubTable != null)
{
    @if (replaceDto.ShowBtnExport)
    {
        @:[ExcelIgnore]
    }
        @:public @(genTable.SubTable.EntityClassName)Dto @(genTable.SubTable.EntityClassName)Nav { get; set; }
@:
}

@if (genTable.TplCategory == "subNavMore" && genTable.SubTable != null)
{
    @if (replaceDto.ShowBtnExport)
    {
        @:[ExcelIgnore]
    }
        @:public List<@(genTable.SubTable.EntityClassName)Dto> @(genTable.SubTable.EntityClassName)Nav { get; set; }
@:
}
@foreach (var column in dicts)
{
    if (column.IsExport)
    {
        @:[ExcelColumn(Name = "@(column.FieldDesc == "" ? column.CsharpField : column.FieldDesc)")]
        @:public string @(column.CsharpField)Label { get; set; }
    }
}
    }
}